<?php
require_once '../sub/init.php';
require_once 'chkUadm.php';
if(!is_mobile())header("Location: ./");
if($submitok=='shop_my_set_modpass_update'){
	if(!in_array('modpass',$QXARR))exit(noauth('权限不足'));
	if (str_len($old_password)<6 || str_len($old_password)>20)json_exit(array('flag'=>0,'msg'=>'【旧密码】长度请控制在6-20字节以内。'));
	if (str_len($form_password1)<6 || str_len($form_password1)>20)json_exit(array('flag'=>0,'msg'=>'【新密码】长度请控制在6-20字节以内。'));
	if (str_len($form_password2)<6 || str_len($form_password2)>20)json_exit(array('flag'=>0,'msg'=>'【确认新密码】长度请控制在6-20字节以内。'));
	if ($form_password1 <> $form_password2)json_exit(array('flag'=>0,'msg'=>'两次密码输入不一样，请重试！'));
	$password     = md5(trimm($form_password1));
	$old_password = md5($old_password);
	$rt = $db->query("SELECT id FROM ".__TBL_ADMIN__." WHERE id=".$session_uid." AND password='$old_password'");
	if(!$db->num_rows($rt))json_exit(array('flag'=>0,'msg'=>'【旧密码】不正确，修改失败！'.$old_password));
	$db->query("UPDATE ".__TBL_ADMIN__." SET password='$password' WHERE id=".$session_uid);
	//setcookie("cook_tg_pwd",$password,time()+720000,"/",$_ZEAI['CookDomain']);
	$_SESSION["admpwd"] = $password;
	json_exit(array('flag'=>1,'msg'=>'修改成功！'));
}
$nav='index';
?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $_ADM['admSiteName']; ?></title>
<?php echo HEADMETA; ?>
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="css/m_adm.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<style>
.btmboxinput dl dt{width:25%;font-size:14px}
.btmboxinput dl dd{width:75%}
::-webkit-input-placeholder {font-size:14px}
#shop_my_set_modpassbox_btn{background-color:<?php echo $_ADM['color'];?>}
.admexit{width:80%;font-size:15px;display:block;position:absolute;bottom:80px;left:10%;border-color:#eee}
</style>
</head>
<body>
<?php 
$mini_title='其它管理';$mini_class='top_mini4';
require_once ZEAI.'m/top_mini.php';
?>
<div class="modlist">
	<?php if(ADMQX('log') || ADMQX('logdel')){?>
	<ul>
		<li class="tborder" onClick="zeai.openurl('m_log.php');"><h4>操作日志</h4><span></span></li>
		<li onClick="zeai.openurl('<?php echo HOST;?>');"><h4>相亲平台</h4><span></span></li>
	</ul>
    <?php }?>
    <?php if(in_array('modpass',$QXARR)){?>
	<ul>
		<li class="tborder" id="shop_my_set_modpassbtn"><h4>修改密码</h4><span></span></li>
	</ul>
    <?php }?>
</div>
<div id="shop_my_set_modpassbox" class="btmboxinput">
	<h1>修改后台密码</h1>
	<form id="Zeai__cn_formP">
	<input type="text" name="old_password" id="old_password" class="input" placeholder="请输入旧密码" maxlength="20" onBlur="zeai.setScrollTop(0);" autocomplete="off" >
	<input type="text" name="form_password1" id="form_password1" class="input" placeholder="请输入新密码" maxlength="20" onBlur="zeai.setScrollTop(0);" autocomplete="off" >
	<input type="text" name="form_password2" id="form_password2" class="input" placeholder="再输一次新密码" maxlength="20" onBlur="zeai.setScrollTop(0);" autocomplete="off" >
	<input type="hidden" name="submitok" value="shop_my_set_modpass_update">
	<button type="button" class="btn size4 " id="shop_my_set_modpassbox_btn">确定并保存</button>
	</form>
</div>
<button type="button" onClick="zeai.openurl('exit.php')" class="btn size4 BAI yuan admexit">退出登录</button>

<script>
shop_my_set_modpassbtn.onclick=function(){ZeaiM.div_up({obj:shop_my_set_modpassbox,h:32});};
shop_my_set_modpassbox_btn.onclick=function(){
	if(zeai.empty(o('old_password').value) || zeai.str_len(o('old_password').value)<6){zeai.msg('请输入【旧密码】长度6~20个字节内');	return false;}
	if(zeai.str_len(o('form_password1').value)>20 || zeai.str_len(o('form_password1').value)<6){zeai.msg('请输入【新密码】长度6~20个字节内');return false;}
	if(zeai.str_len(o('form_password2').value)>20 || zeai.str_len(o('form_password2').value)<6){zeai.msg('再输一次【新密码】长度6~20个字节内');	return false;}
	if(o('form_password1').value!=o('form_password2').value){zeai.msg('【新密码】两次输入不一致，请检查');return false;}
	zeai.ajax({url:'m_set'+zeai.extname,form:Zeai__cn_formP},function(e){rs=zeai.jsoneval(e);
		zeai.msg(0);zeai.msg(rs.msg);if(rs.flag==1){setTimeout("div_up_close.click()",1000);}
	});
}
</script>
<?php require_once 'm_btm.php';?>